package pda;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.Insets;
import java.awt.Toolkit;

import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.border.EtchedBorder;

import note.NotePanel;
import diary.DiaryPanel;

/**
 * 
 */

/**
 * @author haiyuzha
 *
 */
public class MainFrame extends JFrame {
	static String[] tools = {
		"Calendar", "Note", "Diary", "Log", "Finance"
	};
	//static Object[] tabs = {};

	private JMenuBar createMenuBar() {
		JPopupMenu.setDefaultLightWeightPopupEnabled(false);
		JMenuBar menuBar = new JMenuBar();
		
		JMenu file = (JMenu)menuBar.add(new JMenu("File"));
		JMenuItem fileMI0 = (JMenuItem)file.add(new JMenuItem("Open"));
		file.add(new JSeparator());
		JMenuItem fileMI1 = (JMenuItem)file.add(new JMenuItem("Exit"));
		
		JMenu options = (JMenu)menuBar.add(new JMenu("Options"));
		JMenuItem optionsMI = (JMenuItem)options.add(new JMenuItem("Date"));
		
		return menuBar;
	}

	private JTabbedPane createTabbedPane() {
		JTabbedPane tabbedPane = new JTabbedPane();
		tabbedPane.setTabPlacement(JTabbedPane.LEFT);
		
		tabbedPane.addTab(tools[0], null);
		tabbedPane.addTab(tools[1], new NotePanel());
		tabbedPane.addTab(tools[2], new DiaryPanel());
		tabbedPane.addTab(tools[3], new JCheckBox());
		/*
		for (int i = 0; i < tools.length; i++) {
			tabbedPane.addTab(tools[i], null);
		}
		*/

		return tabbedPane;
	}

	private void createAndShowGUI() {
		int WIDTH = 1200, HEIGHT = 600;
		//JFrame mainFrame = new JFrame("PDA");
		setSize(WIDTH, HEIGHT);
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation((d.width - WIDTH) / 2, (d.height - HEIGHT) / 2);

		JPanel p = new JPanel() {
			public Insets getInsets() {
				return new Insets(0, 0, 0, 0);	// Border margin
			}
		};
		p.setSize(WIDTH, WIDTH);
		p.setLayout(new BorderLayout());
		p.setBorder(new EtchedBorder());
		p.add(createMenuBar(), BorderLayout.NORTH);
		p.add(createTabbedPane(), BorderLayout.CENTER);

		setContentPane(p);
		setVisible(true);
	}
	/**
	 * @throws HeadlessException
	 */
	public MainFrame() throws HeadlessException {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param arg0
	 */
	public MainFrame(GraphicsConfiguration arg0) {
		super(arg0);
		// TODO Auto-generated constructor stub
		
	}

	/**
	 * @param arg0
	 * @throws HeadlessException
	 */
	public MainFrame(String arg0) throws HeadlessException {
		super(arg0);
		createAndShowGUI();
	}

	/**
	 * @param arg0
	 * @param arg1
	 */
	public MainFrame(String arg0, GraphicsConfiguration arg1) {
		super(arg0, arg1);
		// TODO Auto-generated constructor stub
	}

}
